package com.example.newproject_overseas.components


import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.newproject_overseas.R
import com.example.newproject_overseas.model.entity.ProductList_7

@Composable
fun Product_7_WhiteBox(item: ProductList_7) {
    var ckeck by remember {
        mutableStateOf(false)
    }
    Column(
        modifier = Modifier
            .fillMaxWidth()
            .padding(top = 20.dp, )
            .padding(horizontal = 7.5.dp)

            .background(color = Color(0xffFFFFFF))
    ) {
        //第一行 图标加是否选中
        Row(
            modifier = Modifier
                .fillMaxWidth()

                .background(color = Color(0xffFFF6D4))
        ) {
            Image(
                painter = painterResource(id = R.drawable.productlist_7_img),
                contentDescription = null,
                modifier = Modifier
                    .padding(start = 20.dp, top = 10.dp)
                    .height(40.dp)
            )
            Spacer(modifier = Modifier.weight(1f))
            Image(
                painter = painterResource(id = if (ckeck == false) R.drawable.productlist7_check_false else R.drawable.productlist7_check_true),
                contentDescription = null,
                modifier = Modifier
                    .padding(start = 20.dp, top = 10.dp, end = 18.5.dp)
                    .clickable { ckeck = !ckeck }

                    .size(28.5.dp)
            )
        }
        //第二行
        Row(
            modifier = Modifier
                .fillMaxWidth()
                .padding(top = 20.dp)
        ) {
            Column(
                modifier = Modifier
                    .weight(1f)
                    .padding(start = 20.dp)
            ) {
                Text(text = "Loan amount (₹)", fontSize = 15.sp, color = Color(0xff999999))
                Text(
                    text = item.Loanamount,
                    fontSize = 22.5.sp,
                    color = Color(0xff161616),
                    modifier = Modifier.padding(start = 29.5.dp, top = 8.5.dp)
                )
            }
            Column(
                modifier = Modifier
                    .weight(1f)
                    .padding(start = 20.dp)
            ) {
                Text(text = "Loan amount (₹)", fontSize = 15.sp, color = Color(0xff999999))
                Text(
                    text = item.Loanamount,
                    fontSize = 22.5.sp,
                    color = Color(0xff161616),
                    textAlign = TextAlign.Center,
                    modifier = Modifier.padding(start = 29.5.dp, top = 8.5.dp)
                )
            }
        }
        //第三行 灰色的白框
        if (item.productlist7Box != null) {
            Column(
                modifier = Modifier
                    .padding(top = 20.dp)
                    .fillMaxWidth()
                    .padding(horizontal = 10.dp)
            ) {
                Row(modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 18.dp)) {
                    Text(
                        text = "Interest:", fontSize = 15.sp,
                        color = Color(0xff999999),
                        modifier = Modifier.padding(start = 10.dp)
                    )
                    Spacer(modifier = Modifier.weight(1f))
                    Text(
                        text = item.productlist7Box.Interest, fontSize = 15.sp,
                        color = Color(0xff252525),
                        modifier = Modifier.padding(end=10.dp)
                    )
                }
                Row(modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 18.dp)) {
                    Text(
                        text = "Total service charge:", fontSize = 15.sp,
                        color = Color(0xff999999),
                        modifier = Modifier.padding(start = 10.dp)
                    )
                    Spacer(modifier = Modifier.weight(1f))
                    Text(
                        text = item.productlist7Box.Total, fontSize = 15.sp,
                        color = Color(0xff252525),
                        modifier = Modifier.padding(end=10.dp)
                    )
                }
                Row(modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 18.dp)) {
                    Text(
                        text = "Amount received:", fontSize = 15.sp,
                        color = Color(0xff999999),
                        modifier = Modifier.padding(start = 10.dp)
                    )
                    Spacer(modifier = Modifier.weight(1f))
                    Text(
                        text = item.productlist7Box.Amount, fontSize = 15.sp,
                        color = Color(0xff252525),
                        modifier = Modifier.padding(end=10.dp)
                    )
                }
                Row(modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 18.dp)) {
                    Text(
                        text = "Amount repaid:", fontSize = 15.sp,
                        color = Color(0xff999999),
                        modifier = Modifier.padding(start = 10.dp)
                    )
                    Spacer(modifier = Modifier.weight(1f))
                    Text(
                        text = item.productlist7Box.Amountrepaid, fontSize = 15.sp,
                        color = Color(0xff252525),
                        modifier = Modifier.padding(end=10.dp)
                    )
                }
                Spacer(modifier = Modifier.height(20.dp))
            }

        } else {

        }
    }
}



